package ch.wanandroid.view;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import java.util.List;

import butterknife.BindView;
import ch.wanandroid.comr.wanandroid.R;
import ch.wanandroid.lib.banner.BannerItem;
import ch.wanandroid.lib.banner.BaseBanner;
import ch.wanandroid.lib.banner.SimpleImageBanner;
import ch.wanandroid.lib.banner.ZoomInEnter;
import ch.wanandroid.lib.net.beans.BannerResponse;
import ch.wanandroid.present.HomePresent;

/**
 * Author: ch
 * Date: 2018/10/20 9:48
 * Description: ${DESCRIPTION}
 */

public class HomeFragment extends MVPBaseFragment<IHomeView, HomePresent> implements IHomeView {

    Context mContext;
    @BindView(R.id.my_banner)
    SimpleImageBanner mBanner;

    @Override
    protected void initData() {
        mPresenter.fetch();
        //mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
    }

    @Override
    protected void setLayoutId() {
        layoutId = R.layout.fragment_home;
    }

    @Override
    protected HomePresent createPresenter() {
        mPresenter = new HomePresent();
        return mPresenter;
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mContext = context;
    }

    @Override
    public void showLoading() {

    }
    @Override
    public void showData(List<BannerItem> data) {
        mBanner
                .setPeriod(3000)
                .setData(data)
                .setSelectAnim(ZoomInEnter.class)
                .startScroll()
                .setOnItemClickL(new BaseBanner.OnItemClickL() {
                    @Override
                    public void onItemClick(int position) {
                        startActivity(new Intent(getContext(),WebViewActivity.class));
                    }
                });
    }
}
